package com.oct.ywsc.core;

import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Map;

public class StringUtil {


    public static final String SPLIT_FLAG = ",";

    /**
     * 格式化sql
     * @param sql
     * @param paramKeyList 参数key列表
     * @param paramMap 参数值map
     * @return
     */
    public static String formatSql(String sql, List<String> paramKeyList, Map<String,String> paramMap){
        if (!CollectionUtils.isEmpty(paramKeyList)){
            for (String paramKey : paramKeyList) {
                String paramValue = paramMap.get(paramKey);
                sql = sql.replace("#{"+paramKey+"}",paramValue).replace("${"+paramKey+"}",paramValue);

            }
        }

        return sql;
    }
}
